package com.tuu.utils;
import org.springframework.stereotype.Component;
@Component
public class MyUtils {
    //随机字符串
    public String randomString(int len) {
        int len2 =  len>0?len:46;
        String chars ="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprswxyz2345678";    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/

        //1.隐式转换
        double maxPos = chars.length();
        String pwd ="";
        for (int i = 0; i < len; i++) {
            pwd += chars.charAt((int)Math.floor(Math.random() * maxPos));
        }
        return pwd;
    }
    //得到随机整数
    public int GetRandomNum(int Min,int Max) {
        int Range = Max - Min;
        double Rand = Math.random();
        //round +0.5  再取整
        return (int)(Min + Math.round(Rand * Range));
    }
}